package hi.Android;


import java.io.InputStream;
import android.app.Activity;
import android.media.MediaPlayer;

	public class TextToSpeechAndroid extends Activity  {
	    
	    public void getTextToSpeech(String text) throws Exception
	    {
	    	framework obj=new framework();
			InputStream line= obj.gsearch("http://translate.google.com/translate_tts?" + "q="
	                + text.replace(" ", "%20") + "&tl=en");
			play(text);
			//MsgLog.write("hello");
	    }
void play(String name)
{
	MediaPlayer mp = new MediaPlayer();        		
		
	try
	{
		//Tells the media player where the source for the .mp3 is.  Also, replaces spaces with %20 (URL syntax)
		String URL="http://translate.google.com/translate_tts?" + "q="
                + name.replace(" ", "%20") + "&tl=en"+".mp3";
		mp.setDataSource(URL);
		mp.prepare();
		mp.start();
	
	}
	catch(Exception e)
	{
		//Catches network exceptions
		System.out.println("Exception: " + e);
	}
}
	    		
	    }
	    
	     

	



